package com.moleq.models;

import com.moleq.db.DatabaseSchema;

import android.R.integer;

public class Scanner implements IDevModel {
	// sn_no integer NOT NULL,
	// sn_port integer NOT NULL,
	// sn_device_name varchar(30) NULL,
	// sn_baud varchar(10) NULL,
	// sn_parity varchar(1) NULL,
	// sn_data_bits integer NULL,
	// sn_stop_bits integer NULL,
	// sn_disable_cmd varchar(50) NULL,
	// sn_enable_cmd varchar(50) NULL,
	// sn_end_char varchar(50) NULL,
	// sn_chk_digit varchar(1) NULL,
	// sn_data_format varchar(10) NULL,
	// sn_weight_format integer NULL,
	// sn_using varchar(1) NULL,
	// create_datetime varchar(14) NULL,
	// update_datetime varchar(14) NULL
	private int no;
	private int port;
	private String deviceName;
	private String baud;
	private String parity;
	private int dataBits;
	private int stopBits;
	private String disableCmd;
	private String enableCmd;
	private String endChar;
	private String chkDigit;
	private String dataFormat;
	private int weightFormat;
	private String using;
	private String create_datetime;
	private String update_datetime;

	public Scanner() {
	}

	public Scanner(int no, int port, String deviceName, String baud,
			String parity, int dataBits, int stopBits, String disableCmd,
			String enableCmd, String endChar, String chkDigit,
			String dataFormat, int weightFormat, String using) {
		this.no = no;
		this.port = port;
		this.deviceName = deviceName;
		this.parity = parity;
		this.baud = baud;
		this.dataBits = dataBits;
		this.stopBits = stopBits;
		this.disableCmd = disableCmd;
		this.enableCmd = enableCmd;
		this.endChar = endChar;
		this.chkDigit = chkDigit;
		this.dataFormat = dataFormat;
		this.weightFormat = weightFormat;
		this.using = using;
	}
	
	public Scanner(int no, int port, String deviceName, String baud,
			String parity, int dataBits, int stopBits, String disableCmd,
			String enableCmd, String endChar, String chkDigit,
			String dataFormat, int weightFormat, String using,String create_datetime,String update_datetime) {
		this.no = no;
		this.port = port;
		this.deviceName = deviceName;
		this.parity = parity;
		this.baud = baud;
		this.dataBits = dataBits;
		this.stopBits = stopBits;
		this.disableCmd = disableCmd;
		this.enableCmd = enableCmd;
		this.endChar = endChar;
		this.chkDigit = chkDigit;
		this.dataFormat = dataFormat;
		this.weightFormat = weightFormat;
		this.using = using;
		this.create_datetime = create_datetime;
		this.update_datetime = update_datetime;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getDeviceName() {
		return deviceName;
	}

	public void setDeviceName(String deviceName) {
		this.deviceName = deviceName;
	}

	public String getBaud() {
		return baud;
	}

	public void setBaud(String baud) {
		this.baud = baud;
	}

	public String getParity() {
		return parity;
	}

	public void setParity(String parity) {
		this.parity = parity;
	}

	public int getDataBits() {
		return dataBits;
	}

	public void setDataBits(int dataBits) {
		this.dataBits = dataBits;
	}

	public int getStopBits() {
		return stopBits;
	}

	public void setStopBits(int stopBits) {
		this.stopBits = stopBits;
	}

	public String getDisableCmd() {
		return disableCmd;
	}

	public void setDisableCmd(String disableCmd) {
		this.disableCmd = disableCmd;
	}

	public String getEnableCmd() {
		return enableCmd;
	}

	public void setEnableCmd(String enableCmd) {
		this.enableCmd = enableCmd;
	}

	public String getEndChar() {
		return endChar;
	}

	public void setEndChar(String endChar) {
		this.endChar = endChar;
	}

	public String getChkDigit() {
		return chkDigit;
	}

	public void setChkDigit(String chkDigit) {
		this.chkDigit = chkDigit;
	}

	public String getDataFormat() {
		return dataFormat;
	}

	public void setDataFormat(String dataFormat) {
		this.dataFormat = dataFormat;
	}

	public int getWeightFormat() {
		return weightFormat;
	}

	public void setWeightFormat(int weightFormat) {
		this.weightFormat = weightFormat;
	}

	public String getUsing() {
		return using;
	}

	public void setUsing(String using) {
		this.using = using;
	}

	public String getCreate_datetime() {
		return create_datetime;
	}

	public void setCreate_datetime(String create_datetime) {
		this.create_datetime = create_datetime;
	}

	public String getUpdate_datetime() {
		return update_datetime;
	}

	public void setUpdate_datetime(String update_datetime) {
		this.update_datetime = update_datetime;
	}

	@Override
	public boolean isActive() {
		return getUsing().equals("Y");
	}

	@Override
	public String getDevice() {
		// TODO Auto-generated method stub
		return "Scanner";
	}
	
	public String toMGData(String Action) {
		String Result = Action + "|"
				+ DatabaseSchema.ScannerSetting.SCHEMA_NAME + "|(" + getNo()
				+ "," + getPort() + "," + CheckNull(getDeviceName()) + ","
				+ CheckNull(getBaud()) + "," + CheckNull(getParity()) + ","
				+ getDataBits() + "," + getStopBits() + ","
				+ CheckNull(getDisableCmd()) + "," + CheckNull(getEnableCmd())
				+ "," + CheckNull(getEndChar()) + ","
				+ CheckNull(getChkDigit()) + "," + CheckNull(getDataFormat())
				+ "," + getWeightFormat() + "," + CheckNull(getUsing()) + ","
				+ CheckNull(getCreate_datetime()) + ","
				+ CheckNull(getUpdate_datetime()) + ")";
		return Result;
	}

	public String CheckNull(String value) {
		if (value == null) {
			return null;
		} else {
			return "'" + value + "'";
		}
	}
}
